Introduction
If you are new to QuickTime, this chapter is designed to get you oriented, starting from the beginning. It sets out by answering the frequently asked questions that always pop up, then it diagrams the structure of QuickTime in a five-layer model, and finally it defines some of the terms and concepts that we'll use in later chapters.
If you have already worked with QuickTime, you should still skim this chapter for ideas. QuickTime has grown a lot recently, so the current version of the software may support concepts and features that are new to you.
Frequently Asked Questions
People with different technical backgrounds tend to ask a similar set of questions when they first encounter QuickTime. What is it? How do I get it? How do I use it? So we'll start out by answering these basic questions.
- What is QuickTime?
QuickTime is a system-level code package that resides on the user's computer and supports a variety of multimedia tasks. As your code runs, it can call QuickTime to create and show movies, play sounds and music, and animate the user's desktop.
- How is QuickTime implemented?
On Windows computers, QuickTime is implemented through a dynamic-link library (DLL). On Macintosh computers, it is implemented as a set of system extensions that can be installed with Mac OS 7.1.1 or later.
- How do users acquire QuickTime's capabilities?
Apple distributes the QuickTime system software, including the browser plug-in, in separate versions for Mac and Windows. Once the user has installed the system software, applications can call it to access all of QuickTime's functionality. Version 4 of the user package also includes a basic version of the QuickTime Player application. Users can upgrade the application to a more powerful version, QuickTime Player Pro, which includes editing capabilities.
- Users can download the QuickTime 4 software from the Internet free of charge by going to http://www.apple.com/quicktime/ . Apple and other manufacturers also ship QuickTime in new computers as built-in system software, and application developers can license it from Apple to include with their products.
- How do programs use QuickTime?
You access QuickTime by including the necessary programming interfaces in the compilation of your Windows or Macintosh code. QuickTime for Java, just released, contains a set of classes and methods that you can also use to write Java applets and applications that call QuickTime.
- What types of media does QuickTime handle?
Besides processing video data, QuickTime handles still images, animated images (sprites), vector graphics, multiple sound channels, MIDI music, 3D objects, virtual reality objects and panoramas, and text. It adds a wide range of audio-visual possibilities to Mac or Windows applications, Web sites, and multimedia CDs.
- Does QuickTime work differently with Macintosh and Windows?
Although Mac and Windows programs may be structured differently, their interfaces to QuickTime are virtually identical. Just about anything QuickTime can do on one platform, it can do on the other.
- What data formats does QuickTime recognize?
QuickTime curently imports and exports data in more than 70 formats, including most common transport and compression standards. As future standards are added to QuickTime's repertoire, applications created today will work with them automatically. For a list of QuickTime-compatible data formats, see Appendix B.
- What is the QuickTime programming interface (API) like?
Applications and other software access QuickTime's features through a large set of system-level C functions and associated data structures. These API elements are organized into functional groupings, so you can perform specific tasks without having to understand them all. About a hundred additional Macintosh functions--for file and memory management, graphics environment control, and so on--are accessible through the Windows DLL. The result is a single, comprehensive API that supports all of QuickTime's functionality on both the Windows and Macintosh platforms.
- How can I extend QuickTime's capabilities?
QuickTime is a modular tool kit; it is made up of software components that are installed and accessed through a component manager. Although the built-in components carry out most standard multimedia tasks, you are free to replace or augment them with code of your own design. QuickTime includes a full set of services that help you create and install custom components.
- Will QuickTime evolve in the future?
The QuickTime architecture is forward-looking. It is designed to accept and integrate new features without breaking old applications. As new kinds of multimedia appear on the market, QuickTime will be updated to work with them. In many cases, old applications will be able to access the new multimedia without recoding.
Let's watch a typical QuickTime movie. Put the CD in the back of this book into your Windows or Macintosh computer and launch the top-level home page ( Homepage.htm ) with your favorite Web browser. Click on the link to the WatchMe movie. You'll see and hear a short talk by Peter Hoddie, the QuickTime architect, about some of the features of Version 3.0. The picture will look something like the image below. .
If the QuickTime 4 software is not present on your machine, read the downloading instructions on page xxi.
QuickTime architect Peter Hoddie gives you an illustrated overview of some of the capabilities of QuickTime 3. The frame itself is an interactive movie that runs other movies in the viewing area--you can click the buttons on the left side to view them.
QuickTime was originally conceived as a way to bring movement to computer graphics and to let movies run on the desktop. But as QuickTime developed, it became clear that more than movies were involved. Elements that had been designed for static presentation could now be organized along a time line, as changing information.
The result was the concept of change-based media, including not just movies but also animated drawings, music, sound sequences, virtual environments, and active data of all kinds. QuickTime became a generalized way to define time lines and organize information along them. The concept of the movie became a framework in which any sequence of media could be specified, displayed, and controlled. The movie-building process evolved into the five-layer model shown in the diagram below.
Using QuickTime, any collection of change-based data (audible, visual, or both) can be organized as a movie. By calling QuickTime, your code can create, display, edit, copy, and compress movies and movie data in most of the same ways that it currently manipulates text, sounds, and still-image graphics. While the details may get complicated, the top-level ideas are few and fairly simple:
- Movies are bookkeeping structures. They contain all the information necessary to organize data in time, but they don't contain the data itself.
- Movies are made up of tracks. Each track references and organizes a sequence of data of the same type--images, sounds, or whatever--in a time-ordered way.
- Media structures (or just media) reference the actual data that are organized by tracks. Chunks of media data are called media samples.
- A movie file typically contains a movie and its media, bundled together so you can download or transport everything together. But a movie may also access media outside its file--for example, sounds or images from a Web site.
QuickTime's architecture can be described by the five layers shown here. The sounds and images that the user experiences are organized and delivered by means of a movie structure, which is populated with media extracted and processed from files and external devices.
The basic relations between movies, tracks, and media are diagrammed in the next illustration.
The movie diagrammed here contains three tracks: video, music, and text. The material displayed by the tracks is contained in media structures that are located externally and organized by the movie.
QuickTime movies organize media along the time dimension. To manage this dimension, QuickTime defines time coordinate systems that anchor movies and their media data structures to a common temporal reality, the second. Each time coordinate system establishes a time scale that provides the translation between real time and the apparent time in a movie. Time scales are marked in time units--so many per second. The time coordinate system also defines duration, which specifies the length of a movie or a media structure in terms of time units. A particular point in a movie can then be identified by the number of time units elapsed to that point. Each track in a movie contains a time offset and a duration, which determine when the track begins playing and for how long. Each media structure also has its own time scale, which determines the default time units for data samples of that media type.
A component is a piece of QuickTime code that provides a defined set of services to one or more clients. QuickTime responds to your software calls by repeatedly invoking its various components. In addition, QuickTime components often call each other. Much of the time your application does not need to know which components QuickTime is using to accomplish the tasks you specify.
QuickTime is made up of some 200 components, each of which performs a specific job and responds to a defined programming interface. At any given point in a QuickTime programming project, you need be concerned only with the components that your project uses.
So when you raise the hood on QuickTime, you're not staring at a tangle of hoses and gears; it looks more like a stack of clearly labeled boxes. You can change its functionality by opening just one or two boxes. Also, you can start working with QuickTime without needing to know what's in all of the boxes.
This kind of modularity makes it much simpler to program for QuickTime because your code is always dealing with standardized interfaces. It also makes it easy for you to extend the operation of QuickTime by adding a new component or to modify it by replacing a built-in component with one you have written. For example, you might want to revise a component to take advantage of a piece of hardware that your company sells.
QuickTime's component pieces fall into several basic categories:
- The Movie Toolbox provides all the services that other code needs to build movies and movie files.
- Movie controllers display movies and provide user playback controls.
- Media handlers interpret and manipulate a media's sample data in ways that are appropriate for its format.
- Capture components include video digitizers and sequence grabbers with their associated channel and panel components. They let you obtain digitized data from external sources, such as video capture boards and digital cameras.
- Movie data exchange components let you import data from non-movie sources (such as CD tracks) into QuickTime movies and export data to non-movie formats (such as AVI or WAVE files).
- Codecs ( compressors/ decompressors) provide compression and decompression services for media such as sounds and image sequences.
- Transcoders translate data from one compressed format to another.
- Video digitizers convert analog video data to digital form.
- Video output components let you send QuickTime video to devices (such as high-end AV gear) that are not recognized as displays by the computer's operating system.
- Graphics importers display still images obtained from data in various file formats, such as JPEG, PNG, and GIF.
- Graphics exporters store still images in the same formats that graphics importers handle.
- Preview components create and display previews (short excerpts) of movie files or other files that QuickTime can import.
- Tween components perform interpolations between values of various data types. Tweening is an advanced technique that is covered in detail in the QuickTime SDK.
- Effects components provide real-time effects and transitions (such as wipes and dissolves) between images inside or outside QuickTime movies.
- The Sprite Toolbox and sprite media handler let you create and manipulate animated graphics called sprites, which may also be wired to report user interactions.
- Text channel components import and export text between movies and external text handling code, such as word processors.
- Clock components generate timing information and schedule time-based callback events.
- Real-time streaming components let you serve and receive movies and live video in real time, without downloading large files.
For a complete list of QuickTime components, see Appendix A.
QuickTime stores most of its data using specialized memory structures called atoms. Movies and their tracks are organized as atoms. Media and data samples are also converted to atoms before being stored in a movie file.
There are two kinds of atoms: classic atoms, which your code accesses by offsets, and QT atoms, for which QuickTime provides a full set of access tools. Atoms that contain only data, and not other atoms, are called leaf atoms.
QT atoms can nest indefinitely, forming hierarchies that are easy to pass from one process to another. Also, QuickTime provides a powerful set of tools by which you can search and manipulate QT atoms. You can use these tools to search through QT atom hierarchies until you get to leaf atoms, then read the leaf atom's data from its various fields.
Each atom has a type code that determines the kind of data stored in it. By storing data in typed atoms, QuickTime minimizes the number and complexity of the data structures that you need to deal with. It also helps your code ignore data that's not of current interested when it interprets a data structure.
Multiplatform Programming
If you are like most programmers, you hate to write the same code twice. You will welcome the fact that QuickTime is truly multiplatform. Its application programming interface is essentially the same on Windows and Macintosh; the same QuickTime-related source code will compile and run correctly on both platforms; and anything you can do with QuickTime on a Macintosh computer you can also do on a computer running Windows 95, 98, or NT 4.0. In addition, QuickTime for Java lets you write Java code that accesses QuickTime on both Windows or Macintosh computers.
If you're thinking of developing a multimedia application that uses QuickTime, this level of compatibility means that you will have access to the same QuickTime services across platforms, and you can easily produce both Mac and Windows versions of your software.
Here are the technical details of QuickTime's implementations for the Mac, Windows 95, Windows 98, Windows NT, and Java:
- On the Mac, QuickTime is implemented as a set of system extensions that run under System 7.0 or later on most Macintosh computers. All the user needs is a 68020 processor or better with support for Color QuickDraw, or any PowerPC processor.
- On Windows 95, Windows 98, and Windows NT, QuickTime is implemented as a dynamic-link library (DLL) and works on any PC-compatible computer with a 66 MHz 80486 processor or better. It supports Microsoft DirectDraw and DirectSound, which improve its performance. Users can download runtime implementations of QuickTime with the Player application from the Internet free of charge, and developers can license these items to ship with their products.
- When accessed through Java, QuickTime running on one of these platforms is implemented as a set of classes and methods that gives you access to its functionality. You can write Java applets for both Macintosh and Windows that will share events and display space with native QuickTime.
To watch a short talk about QuickTime multiplatform programming in Windows, double-click Movies/WatchMe-SourceMovies/Windows.mov on the CD. The movie will look like the illustration below. You'll notice that it is one of the movies linked into the WatchMe movie shown in A typical QuickTime movie . This time it is running in the QuickTime Player application.
This short movie discusses some of the techniques you use when writing QuickTime code for the Windows platform. You can find it on the CD at Movies/WatchMe-SourceMovies/Windows.mov . When you launch it by itself, you invoke the QuickTime Player application. For information about its playback controls, see page 33.
Multiplatform applications based on QuickTime are not only able to access existing QuickTime Web sites--they also work with most industry-standard movie formats. The more QuickTime features you use, the more benefits you can provide over the current choices that are available for Windows only, such as Video for Windows and DirectShow. You'll enjoy a wider range of capabilities and a higher level of compatibility with existing standards, both new and old. This is why most multimedia content developers work with tools that support QuickTime.
You don't need to know a lot about QuickTime to understand what it's good for. Just tuck away these basic facts:
- QuickTime is the most widely used software tool kit for creating and displaying movies, animations, music, and virtual reality.
- It's everywhere; QuickTime is installed on virtually all Macintosh computers and more than two-thirds of Windows PCs.
- The QuickTime system code is fully accessible in the Windows, Macintosh, and Java programming environments.
- You can integrate QuickTime capabilities into your application with as few as a dozen calls.
- Because QuickTime is modular, you can change its features by modifying or replacing individual components.
In an earlier diagram we showed a simplified architectural model of QuickTime in five layers. In the next five chapters we'll explore this diagram layer by layer, starting in Chapter 2 with the user's experience. The whole point of QuickTime is to produce graphics and sound on the user's computer, so the place to begin is by understanding the final output. QuickTime's key deliverable is the movie, but you'll see that movies cover a lot of ground, from video stored on disk to music, animations, virtual reality environments, and live action streamed over the Internet.
Descending one level, Chapter 3 talks about the ways that QuickTime movies are delivered to the viewer. Besides live streaming, there are a variety of techniques for packaging movies to be accessed from disks, CD-ROM, and the Internet.
Chapter 4 goes into the internal structure of QuickTime movies. You'll see that this structure gives you a high degree of flexibility in timing and presenting the movie's media. The fact that one structure works with the entire range of media types also means that many of the programming tricks you learn for one media type will work with others.
At a finer level of detail, Chapter 5 describes QuickTime's techniques for referencing and processing the data that movies organize, including compression and decompression methods. QuickTime is designed to do most of the routine work automatically, so you can concentrate on higher-level design. But understanding the nuts and bolts of media handling can help you optimize the movies you build.
Finally, Chapter 6 discusses the facilities that QuickTime provides for capturing, storing, and creating the raw data that go into movies. It describes the QuickTime components that grab video and sound sequences from external devices, as well as the sophisticated built-in toolkits that let you create your own animation and music.
Remember that QuickTime is a general technology for working with change-based media. Part One of this book (Chapters 1 through 6) discusses movie-building because that is a central concept. But you can be a QuickTime programmer without ever creating or playing a movie--for example, if you work with desktop animation or synthetic music. Once you have read Part One and understand movies, you'll have the background knowledge to branch out into the other areas that we'll explore in Part Two.